package xyz.zhzby.cyzx.com.controller;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import xyz.zhzby.cyzx.com.dto.request.DiscussionAddRequest;
import xyz.zhzby.cyzx.com.dto.request.DiscussionPageRequest;
import xyz.zhzby.cyzx.com.dto.request.DiscussionReportRequest;
import xyz.zhzby.cyzx.com.dto.response.DiscussionResponse;
import xyz.zhzby.cyzx.com.entity.Discussion;
import xyz.zhzby.cyzx.com.service.IDiscussionService;
import xyz.zhzby.cyzx.security.util.CyzxSecurityContextHolder;
import xyz.zhzby.cyzx.servicebase.domain.PageResponse;
import xyz.zhzby.cyzx.servicebase.domain.RestResponse;

import java.util.List;

/**
 * @author zby
 * @date 2022/02/15
 */
@RestController
@RequestMapping("/com")
@ApiModel("试题分类相关API")
public class DiscussionController {

    @Autowired
    private IDiscussionService discussionService;

    @ApiOperation("新增评论/回复")
    @PostMapping("")
    public RestResponse<DiscussionResponse> createDiscuss(@RequestBody DiscussionAddRequest discussionAddRequest) {
        return discussionService.createDiscuss(discussionAddRequest);
    }

    @ApiOperation("分页获取讨论")
    @PostMapping("/list")
    public RestResponse<PageResponse<DiscussionResponse>> getDiscussionList(@RequestBody DiscussionPageRequest discussionPageRequest) {
        return discussionService.getDiscussionList(discussionPageRequest);
    }

    @ApiOperation("举报某个评论")
    @PostMapping("/report")
    public RestResponse<String> reportDiscussion(@RequestBody DiscussionReportRequest discussionReportRequest) {
        return discussionService.reportDiscussion(discussionReportRequest);
    }


}
